package com.zzzyh.forumsystemclient.services.impl;

import com.zzzyh.forumsystemclient.dao.CommentMapper;
import com.zzzyh.forumsystemclient.model.Comment;
import com.zzzyh.forumsystemclient.services.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements ICommentService {
    @Autowired private CommentMapper commentMapper;
    @Override
    public List<Comment> list(int pageNum, int pageSize, Long articleId) {
        return commentMapper.list((pageNum-1)*pageSize, pageSize, articleId);
    }

    @Override
    public Integer total(Long articleId) {
        return commentMapper.total(articleId);
    }

    @Override
    public void add(Comment comment) {
        commentMapper.insertSelective( comment);
    }

    @Override
    public List<Comment> getCommentList(Integer pageNum, Integer pageSize, Integer id) {
        return commentMapper.getCommentList((pageNum-1)*pageSize, pageSize, id);
    }

    @Override
    public Integer getTotalByUserId(Integer id) {
        return commentMapper.getTotalByUserId(id);
    }

    @Override
    public List<Comment> myReply(Integer id  ,Integer pageNum, Integer pageSize, String title) {
        return commentMapper.myReply(id,(pageNum-1)*pageSize, pageSize, title);
    }

    @Override
    public Integer getReplyTotal(Integer id) {
        return commentMapper.getReplyTotal(id);
    }

    @Override
    public void delMyComment(Integer commentId) {
        commentMapper.delMyComment(commentId);
    }
}
